<!-- include "menu" -->
<div id='slide-valider'></div>

<div id='main-site-globalbo-moduleSpace-newsletter'>
	<div id='main-frbNewsletter-main-title'>Newsletter
	</div>
	<textarea id="textareaNewsletter" rows="10" cols="100" class='textarea-content' name="text_area_"></textarea>
</div>

	

<div id="main-frrNewsletter-toolbox">

<input type="button" value="Valider" class="personal-button-right" id='valid-news'>
<input type="button" value="Clear" class="personal-button-right" id='clear-news'>
</div>

<script type="text/javascript" src="{{baseurl}}global/js/globalbo/tiny_mce/tiny_mce.js" ></script >
<script type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        language : "en",
        entity_encoding : 'false',
        theme : "simple"   //(n.b. no trailing comma, this will be critical as you experiment later)
});
var id;
function hideDiv(){
	$('#slide-valider').slideToggle('slow', function() {});
	clearInterval(id);
}

$("#clear-news").click(function(){
	tinyMCE.activeEditor.setContent('');
});

$("#valid-news").click(function(){
	url="{{baseurl}}admin/frbNewsletter/frbNewsletter_MainController/index"
	postData = "content="+tinyMCE.activeEditor.getContent();
		$.ajax({
			type : 'POST',
			url: url,
			cache: false,
			data: postData,
			success: function(html){
			alert(html);
				//Mettre le contenu ici pour indiquer que la newsletter a été envoyé
				if(html=='true'){
					id = setInterval("hideDiv()", 3000);
					$('#slide-valider').html("Newsletter postee");
					$('#slide-valider').slideToggle('slow');
				}else{
					id = setInterval("hideDiv()", 3000);
					$('#slide-valider').html("Echec de l'envoie de la newsletter");
					$('#slide-valider').slideToggle('slow');
				}
			}
		});
});


</script>